home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / libx11.lha / libX11 / text.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-22  |  6.2 KB  |  219 lines

  1. /* Copyright (c) 1996 by Terje Pedersen.  All Rights Reserved   */
  2. /*                                                              */
  3. /* By using this code you will agree to these terms:            */
  4. /*                                                              */
  5. /* 1. You may not use this code for profit in any way or form   */
  6. /*    unless an agreement with the author has been reached.     */
  7. /*                                                              */
  8. /* 2. The author is not responsible for any damages caused by   */
  9. /*    the use of this code.                                     */
  10. /*                                                              */
  11. /* 3. All modifications are to be released to the public.       */
  12. /*                                                              */
  13. /* Thats it! Have fun!                                          */
  14. /* TP                                                           */
  15. /*                                                              */
  16.  
  17. /***
  18.    NAME
  19.      text
  20.    PURPOSE
  21.      text drawing functions
  22.    NOTES
  23.      
  24.    HISTORY
  25.      Terje Pedersen - Mar 21, 1995: Created.
  26. ***/
  27.  
  28. #include <intuition/intuition.h>
  29. #include <intuition/intuitionbase.h>
  30.  
  31. #include <graphics/gfx.h>
  32. #include <graphics/gfxbase.h>
  33. #include <graphics/gfxmacros.h>
  34. #include <graphics/displayinfo.h>
  35. #include <devices/timer.h>
  36.  
  37. #include <proto/intuition.h>
  38. #include <proto/graphics.h>
  39. #include <proto/gadtools.h>
  40. #include <proto/layers.h>
  41.  
  42. #include <dos.h>
  43. #include <signal.h>
  44. #include <stdlib.h>
  45. #include <time.h>
  46. #include <stdio.h>
  47.  
  48. #include "libX11.h"
  49.  
  50. /*#define XLIB_ILLEGAL_ACCESS 1*/
  51.  
  52. #include <X11/X.h>
  53. #include <X11/Xlib.h>
  54. #include <X11/Xutil.h>
  55. #include <X11/Intrinsic.h>
  56. #include <X11/IntrinsicP.h>
  57. #include <X11/CoreP.h>
  58.  
  59. /*
  60. #include <libraries/mui.h>
  61. #include <proto/muimaster.h>
  62. */
  63. #include <X11/Xlibint.h>
  64.  
  65. #include "amigax_proto.h"
  66. #include "amiga_x.h"
  67.  
  68. extern GC      amiga_gc;
  69.  
  70. extern struct Screen *Scr,*wb;
  71. extern Window prevwin;
  72. extern GC prevgc;
  73. extern struct RastPort *drp;
  74. extern int X_relx,X_rely,X_right,X_bottom;
  75. extern int X11muiapp;
  76.  
  77. XDrawString(d,win,gc,x,y,string,length)
  78. Display *d;
  79. GC gc;
  80. Drawable win;
  81. int x,y,length;
  82. char *string;
  83.   char Xtempstr[256];
  84.   struct IntuiText itext;
  85.  
  86.   strncpy(Xtempstr,string,length);
  87.   Xtempstr[length]=0;
  88.  
  89. #ifdef DEBUGXEMUL_ENTRY
  90.   printf("(drawing)XDrawString [%s] length %d (%d %d) -> (%d %d)\n",Xtempstr,length,x,y,X_relx+x,X_rely+y-drp->Font->tf_Baseline-1); 
  91. #endif
  92.   if(win!=prevwin) if(!(drp=setup_win(win))) return;
  93.   if(gc!=prevgc) setup_gc(gc);
  94.  
  95.   if(gc->values.font /*&&!X11muiapp*/){
  96.     ULONG new;
  97.     struct TextFont *tf=(struct TextFont*)((sFont*)gc->values.font)->tfont;
  98.     struct TextAttr *tattr=(struct TextAttr*)((sFont*)gc->values.font)->tattr;
  99.     SetFont(drp,tf);
  100.     new=SetSoftStyle(drp,tattr->ta_Style ^ tf->tf_Style,(FSF_BOLD|FSF_UNDERLINED|FSF_ITALIC));
  101. /*    if(tf->tf_Flags==42||tf==(struct TextFont*)amiga_gc->values.font)StripFont(tf);*/
  102.   }
  103.   if(length<1||!string) {/*printf("zero length string in xdrawstring\n");*/ return;}
  104. /*  if(length>80){ printf("large string! %d\n",length); length=80;}*/
  105.   itext.IText=(char *)Xtempstr;
  106.   itext.LeftEdge=0; itext.TopEdge=0; 
  107.   if(gc->values.function==GXinvert||gc->values.function==GXxor) 
  108.     itext.DrawMode=COMPLEMENT;
  109.   else if(gc->values.background==0) itext.DrawMode=JAM1;
  110.   else itext.DrawMode=JAM2;
  111.   itext.ITextFont=NULL;
  112.   itext.NextText=NULL;
  113.   itext.FrontPen=gc->values.foreground; itext.BackPen=gc->values.background;
  114.   PrintIText(drp,&itext,X_relx+x,X_rely+y-drp->Font->tf_Baseline);
  115. }
  116.  
  117. XDrawImageString(display, win, gc, x, y, string, length)
  118.      Display *display;
  119.      Window win;
  120.      struct _XGC *gc;
  121.      int x, y;
  122.      char *string;
  123.      int length;
  124. {
  125.   char Xtempstr[256];
  126.   struct IntuiText itext;
  127.   int origx,origy;
  128. #ifdef DEBUGXEMUL_ENTRY
  129.   printf("(events)XDrawImageString %d,%d %s (%d)in window %d\n",x,y,string,length,(int)win);
  130. #endif 
  131.   if(win!=prevwin) if(!(drp=setup_win(win))) return;
  132.   if(gc!=prevgc) setup_gc(gc);
  133.  
  134.   if(gc->values.font /*&&!X11muiapp*/){
  135.     struct TextFont *tf=(struct TextFont*)((sFont*)gc->values.font)->tfont;
  136.     struct TextAttr *tattr=(struct TextAttr*)((sFont*)gc->values.font)->tattr;
  137.     SetFont(drp,tf);
  138. /*    if(tf->tf_Flags==42||tf==(struct TextFont*)amiga_gc->values.font)StripFont(tf);*/
  139.   }
  140.   origx=X_relx+x;
  141.   origy=X_rely+y-drp->Font->tf_Baseline;
  142.  
  143.   if(length<1||!string) {/*printf("zero length string in xdrawimagestring\n");*/ return;}
  144. /*
  145.   if(length*drp->Font->tf_XSize+origx>X_right){
  146.     length=(int)((X_right-origx)/drp->Font->tf_XSize);
  147.     if(length<0)length=0;
  148.     printf("large string! %d\n",length);
  149.   }*/
  150.   strncpy(Xtempstr,string,length);
  151.   Xtempstr[length]=0;
  152.   itext.IText=Xtempstr; itext.LeftEdge=0; itext.TopEdge=0;
  153.   if(gc->values.function==GXinvert||gc->values.function==GXxor) 
  154.     itext.DrawMode=COMPLEMENT;
  155.   else itext.DrawMode=JAM2;
  156.   itext.ITextFont=NULL; itext.NextText=NULL;
  157.   itext.FrontPen=gc->values.foreground; itext.BackPen=gc->values.background;
  158.   PrintIText(drp,&itext,origx,origy);
  159. }
  160.  
  161. XDrawText16(display, drawable, gc, x, y, items, nitems)
  162.      Display *display;
  163.      Drawable drawable;
  164.      GC gc;
  165.      int x, y;
  166.      XTextItem16 *items;
  167.      int nitems;
  168. {/*             File 'do_text.o'*/
  169. #if (DEBUGXEMUL_ENTRY) || (DEBUGXEMUL_WARNING)
  170.   printf("WARNING: XDrawText16\n");
  171. #endif
  172.   return(0);
  173. }
  174.  
  175. XDrawString16(display, drawable, gc, x, y, string, length)
  176.      Display *display;
  177.      Drawable drawable;
  178.      GC gc;
  179.      int x, y;
  180.      char *string;
  181.      int length;
  182. {/*           File 'do_text.o'*/
  183. #if (DEBUGXEMUL_ENTRY)
  184.   printf("XDrawString16\n");
  185. #endif
  186.   XDrawString(display,drawable,gc,x,y,string,length);
  187.   return(0);
  188. }
  189.  
  190. XDrawImageString16(display, win, gc, x, y, string, length)
  191.      Display *display;
  192.      Drawable win;
  193.      GC gc;
  194.      int x, y;
  195.      char *string;
  196.      int length;
  197. {/*      File 'do_text.o'*/
  198. #ifdef DEBUGXEMUL_ENTRY
  199.   printf("XDrawImageString16\n");
  200. #endif
  201.   XDrawImageString(display,win,gc,x,y,string,length);
  202.   return(0);
  203. }
  204.  
  205. XDrawText(display, drawable, gc, x, y, items, nitems)
  206.      Display *display;
  207.      Drawable drawable;
  208.      GC gc;
  209.      int x, y;
  210.      XTextItem *items;
  211.      int nitems;
  212. {/*               File 'do_text.o'*/
  213. #if (DEBUGXEMUL_ENTRY) || (DEBUGXEMUL_WARNING)
  214.   printf("WARNING: XDrawText\n");
  215. #endif
  216.   return(0);
  217. }
  218.